<template>
  <el-container>
    <el-header id="header" style="z-index: 10">
      <el-row type="flex" justify="space-between">
        <el-col :xs="12" :span="5" class="header-col" style="text-align: left">
          <img
            alt="Project logo"
            src="../assets/logo.png"
            style="max-width: 100%; height: 50px; margin-top: 5px"
          />
        </el-col>
        <el-col :xs="0" :sm="18" :md="14" :lg="12" :xl="9" class="header-col">
          <el-menu
            :default-active="currentComp"
            class="el-menu"
            id="header-menu"
            mode="horizontal"
            @select="handleSelect"
            background-color="#FFFFFF"
            text-color="#000000"
            active-text-color="#1F884F"
            :router="true"
          >
            <el-menu-item
              v-for="item in navList"
              :key="item.index"
              :index="item.index"
            >
              {{ item.navItem }}
            </el-menu-item>
          </el-menu>
        </el-col>
        <el-col :xs="7" :sm="0" :md="0" :lg="0" :xl="0">
          <el-dropdown
            @command="handleSelect"
            trigger="click"
            placement="bottom-end"
          >
            <span class="el-dropdown-link">
              <i
                style="font-size: 40px; margin-top: 10px; color: #1f884f"
                class="el-icon-menu"
              ></i>
            </span>
            <template #dropdown>
              <el-dropdown-menu style="width: 300px">
                <el-dropdown-item command="home">HOME</el-dropdown-item>
                <el-dropdown-item command="toolkit">TOOLKIT</el-dropdown-item>
                <el-dropdown-item command="tutorial">TUTORIAL</el-dropdown-item>
                <el-dropdown-item command="casestudy"
                  >CASE STUDY</el-dropdown-item
                >
                <el-dropdown-item command="getintouch"
                  >CONTACT US</el-dropdown-item
                >
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-header>
    <el-main id="main" style="padding: 0">
      <div>
        <keep-alive>
          <component
            :is="currentComp"
            v-on:change-comp="handleButton($event)"
          ></component>
        </keep-alive>
      </div>
    </el-main>
    <div id="page-footer">
      <div id="footer-content">
        <i class="el-icon-message"></i>mail: lid_cbalt@163.com
      </div>
    </div>
    <p id="currCompP" style="display: none">{{ currentComp }}</p>
    <p id="tutorComp" style="display: none">one</p>
  </el-container>
</template>

<script>
import home from "./Home.vue";
import toolkit from "./Toolkit.vue";
import tutorial from "./Tutorial.vue";
import casestudy from "./CaseStudy.vue";
import getintouch from "./GetInTouch.vue";
export default {
  name: "Page",
  components: {
    home,
    toolkit,
    tutorial,
    casestudy,
    getintouch,
  },
  data() {
    return {
      currentComp: "home",
      navList: [
        { index: "home", navItem: "HOME" },
        { index: "toolkit", navItem: "TOOLKIT" },
        { index: "tutorial", navItem: "TUTORIAL" },
        { index: "casestudy", navItem: "CASE STUDY" },
        { index: "getintouch", navItem: "CONTACT US" },
      ],
    };
  },
  methods: {
    handleSelect(path) {
      //alert([path]);
      if (path != "phonemode") {
        this.currentComp = path;
      }
    },
    handleButton(path) {
      console.log("go to " + path);
      this.currentComp = path;
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
#header {
  height: 60px;
  position: fixed;
  width: 100%;
  top: 0px;
  background-color: rgb(255, 255, 255);
  border-bottom: solid 1px #e6e6e6;
  box-sizing: content-box;
}
#header-menu {
  min-width: 552px;
}
.header-col {
  height: 60px;
}
.el-dropdown-menu__item {
  width: 260px;
  text-align: center;
  vertical-align: middle;
}
h3 {
  margin: 0px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0px;
}
a {
  color: #42b983;
}
#main {
  margin-bottom: 60px;
}
#page-footer {
  color: white;
  background-color: #323437;
  text-align: right;
  height: 35px;
  position: fixed;
  width: 100%;
  bottom: 0;
  z-index: 10;
}
#footer-content {
  line-height: 35px;
  vertical-align: middle;
  margin-right: 5%;
}
</style>